import Vue from "vue";
import VueRouter from "vue-router";
import Upload from "@/views/Upload";
import AllFile from "@/views/AllFile";
import Download from "@/views/Download";
import Finished from "@/views/Finished";
import Login from "@/views/Login";
import ForgetPasswd from "@/views/ForgetPasswd";
import Register from "@/views/Register";
import RecycleBin from "@/views/RecycleBin/index";
import PathSelector from "@/views/PathSelector";
import Player from "@/views/Player";
import PhotoViewer from "@/views/PhotoViewer";
import Share from "@/views/Share";

Vue.use(VueRouter);

const routes = [
  {
    path: "/",
    redirect: "/allFile"
  },
  {
    path: "/upload",
    name: "Upload",
    component: Upload
  },
  {
    path: "/allFile",
    name: "AllFile",
    component: AllFile
  },
  {
    path: "/download",
    name: "Download",
    component: Download
  },
  {
    path: "/finished",
    name: "Finished",
    component: Finished
  },
  {
    path: "/login",
    name: "Login",
    component: Login
  },
  {
    path: "/register",
    name: "Register",
    component: Register
  },
  {
    path: "/forgetPasswd",
    name: "ForgetPasswd",
    component: ForgetPasswd
  },
  {
    path: "/share",
    name: "Share",
    component: Share
  },
  {
    path: "/recycleBin",
    name: "RecycleBin",
    component: RecycleBin
  },
  {
    path: "/pathSelector/:fileType/:removeId",
    name: "PathSelector",
    component: PathSelector
  },
  {
    path: "/play/:userFileId",
    name: "Player",
    component: Player
  },
  {
    path: "/view/:userFileId",
    name: "PhotoViewer",
    component: PhotoViewer
  }
];

const router = new VueRouter({
  mode: "hash",
  base: __dirname,
  routes
});

const originalPush = VueRouter.prototype.push;

VueRouter.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err);
};

export default router;
